package com.checkchan.ethshare.controller;

import com.checkchan.ethshare.model.ComResponse;
import com.checkchan.ethshare.service.user.AccountService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping(value = "/getAccountList",method = RequestMethod.GET)
    @ApiOperation(value = "获取账户列表",notes = "账户列表",httpMethod = "GET")
    public ComResponse getAccountList(){
        ComResponse res = new ComResponse();
        res.setSuccess(true);
        res.setCode(200);
        res.setMessage("操作成功");
        res.setData(accountService.getAccountList());
        return res;
    }

    @RequestMapping(value = "/checkAccount/{address}",method = RequestMethod.GET)
    @ApiOperation(value = "检查账户是否存在",notes = "检查账户是否存在",httpMethod = "GET")
    public ComResponse checkAccount(@PathVariable String address){
        ComResponse res = new ComResponse();
        res.setSuccess(true);
        res.setCode(200);
        res.setMessage("操作成功");
        res.setData(accountService.checkAccount(address));
        return res;
    }

    @RequestMapping(value = "/getBalance/{address}",method = RequestMethod.GET)
    @ApiOperation(value = "获取账户的余额",notes = "获取账户的余额",httpMethod = "GET")
    public ComResponse getBalance(@PathVariable String address){
        ComResponse res = new ComResponse();
        res.setSuccess(true);
        res.setCode(200);
        res.setMessage("操作成功");
        res.setData(accountService.getBalance(address));
        return res;
    }


}
